package com.xzmzhp.dao.power;

import com.xzmzhp.pojo.power.Menu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 王源(xm)
 * @Date: 2021/5/31 22:36:30
 * @Description: 菜单信息表操作类
 */

@Repository
public interface MenuMapper {

    /**
     * 根据用户权限查询请求路径
     *
     * @param competenceId 权限Id
     * @return 用户对应路径信息息
     */
    @Select("select url from request_path where request_path.id " +
            "in (select id from menu_request where menu_id " +
            "in (select menu_id from competence_menu where competence_id = #{competenceId}))")
    List<String> selectMenuByCompetence(@Param("competenceId") Integer competenceId);

    //TODO 菜单回显

    /**
     * 返回路由
     * @param competenceId 权限Id
     * @param menuState 菜单状态
     * @return 路由信息
     */
    @Select("select menu.menu_id,menu_name,parent_menu,menu_level,route_name,menu_icon from menu " +
            "left join competence_menu on competence_menu.menu_id =menu.menu_id " +
            "where competence_menu.competence_id = #{competenceId} and menu_state = #{menuState}")
    List<Menu> selectRoute(@Param("competenceId") Integer competenceId,@Param("menuState") String menuState);
}
